/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-06-09 10:37:55
 * @LastEditTime : 2023-07-18 10:09:55
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\TunnelSafeStep.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { DelDataButton } from '../Common/options'
import { TunnelInfos } from '../Common/Conversion'

export const TunnelSafeStep = async ({ url, OptionsEvent, ClientData, Permission }) => {
    const tunnelInfoUuid = await TunnelInfos()
    let data = {
        type: '隧道管理',
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'createTime@desc' },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        columns: [
            commonTableList.uuid,
            { ...commonTableList.code, rules: true, hideInSearch: false },
            {
                dataIndex: 'tunnelInfoUuid',
                title: '隧道',
                valueType: 'select',
                valueEnum: tunnelInfoUuid,
                rules: true,
                width: 150,
                hideInSearch: false,
            },
            {
                dataIndex: 'lorR',
                key: 'TunnelLorR',
                title: '部位',
                valueType: 'select',
                valueEnum: BuiltInData.lorR,
                rules: true,
                width: 160,
            },
            {
                dataIndex: 'position',
                title: '测量位置',
                valueType: 'input',
                valueEnum: {},
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'stepValue',
                title: '实测安全距离',
                valueType: 'input',
                valueEnum: {},
                rules: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'alarm',
                title: '报警标志',
                valueType: 'select',
                valueEnum: BuiltInData.alarm,
                rules: true,
                width: 150,
                hideInSearch: false,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            commonTableList.StartTime,
            commonTableList.EndTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 100,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '0cfba5d6-0a80-4c9d-81f5-466cd6d2638b') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
